﻿package mortal.game.view.mount.newMountModuel
{
    import Message.Client.*;
    import Message.DB.Tables.*;
    import Message.Public.*;
    import baseEngine.modifiers.*;
    import com.gengine.core.frame.*;
    import com.gengine.global.*;
    import com.gengine.resource.*;
    import com.greensock.*;
    import com.greensock.easing.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.manager.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import frEngine.effectEditTool.temple.*;
    import frEngine.pools.*;
    import frEngine.primitives.object2d.*;
    import mortal.common.display.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.manager.window3d.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.model.data.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.cd.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.guide.*;
    import mortal.game.view.mount.data.*;
    import mortal.game.view.mount.panel.*;
    import mortal.game.view.shop.*;
    import mortal.game.view.shopMall.data.*;
    import mortal.game.view.signUp.sevenDayLogin.data.*;
    import mortal.game.view.vip.*;
    import mortal.mvc.core.*;

    public class MountInfoPanel extends MountBasePanel
    {
        private var _isAutoBuy:Boolean = false;
        private var _currentIndex:int;
        private var cdData:ICDData;
        private var _mountData:MountData;
        private var _tmountInfo:TMountConfig;
        private var modelX:Number;
        private var _isOverBtn:Boolean;
        private var _isAntoLeveling:Boolean = false;
        private var _delayTimer:Timer;
        private var _startX:Number;
        private var _endX:Number;
        private var _tween1:TweenMax;
        private var _tween2:TweenMax;
        private var _tween3:TweenMax;
        private var _rightPart:MountRightPart;
        private var _equipMentPart:MountEquipPart;
        private var _skillPart:MountSkillPart;
        private var _mountAdvancePanel:MountAdvancePanel;
        private var _mountBg:GImageBitmap;
        private var _autoLevelUpBtn:GLoadingButton;
        private var _nolmalLevelUpBtn:GLoadingButton;
        private var _leftBtn:GLoadedButton;
        private var _rightBtn:GLoadedButton;
        private var _cancelBtn:GLoadingButton;
        private var _turnLeftBtn:GLoadedButton;
        private var _turnRightBtn:GLoadedButton;
        private var _sharpBtn:GLoadingButton;
        private var _autoBuy:GCheckBox;
        private var _levelUpIcon:GImageBitmap;
        private var _name:GImageBitmap;
        protected var _currLevel:BitmapNumberText;
        protected var _nextLevel:BitmapNumberText;
        private var _advanceLevelSprite:GSprite;
        private var _adVanceBtnSprite:GSprite;
        private var _vipIcon:GImageBitmap;
        private var vipSp:ToolTipSprite;
        private var _3dRotationSp:GSprite;
        private var _3dRotationBm:GBitmap;
        private var _window:Window;
        private var _rect3d:Rect3DObject;
        protected var _bodyPlayer:ActionPlayer;
        protected var _img2d:Img2D;
        protected var _mountHangEffect:EffectPlayer;
        protected var _nextMountHangEffect:EffectPlayer;
        protected var _nextBodyPlayer:ActionPlayer;
        private var _frameTimer:FrameTimer;
        private var _isUseUnBinGold:Boolean;
        private var turnValue:int;

        public function MountInfoPanel(param1:Window)
        {
            this._window = param1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._3dRotationSp = UICompomentPool.getUICompoment(GSprite);
            this._3dRotationSp.x = 18;
            this._3dRotationSp.y = 35;
            this._3dRotationSp.mouseEnabled = true;
            this._window.contentTopOf3DSprite.addChild(this._3dRotationSp);
            this._3dRotationBm = GlobalClass.getBitmap(BitmapDataConst.AlphaBMD);
            this._3dRotationBm.width = 485;
            this._3dRotationBm.height = 440;
            this._3dRotationSp.addChild(this._3dRotationBm);
            this._mountBg = UIFactory.gImageBitmap("", 14, 35, this);
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.mountTitleBg, 7, 33, this._window.contentTopOf3DSprite));
            this._name = UIFactory.gImageBitmap("", 209, 45, this._window.contentTopOf3DSprite);
            this._turnLeftBtn = UIFactory.gLoadedButton(ImagesConst.MountLeft_upSkin, 61, 34, 33, 37, this._window.contentTopOf3DSprite);
            this._turnRightBtn = UIFactory.gLoadedButton(ImagesConst.MountRight_upSkin, 409, 34, 33, 37, this._window.contentTopOf3DSprite);
            this.vipSp = UICompomentPool.getUICompoment(ToolTipSprite);
            this.vipSp.x = 35;
            this.vipSp.y = 80;
            this.vipSp.toolTipData = this.getVipToolTip;
            this._window.contentTopOf3DSprite.addChild(this.vipSp);
            this.vipSp.configEventListener(MouseEvent.ROLL_OVER, this.showEffect);
            this.vipSp.configEventListener(MouseEvent.ROLL_OUT, this.hideEffect);
            this._vipIcon = UIFactory.gImageBitmap("", 0, 0, this.vipSp);
            this._rightPart = UICompomentPool.getUICompoment(MountRightPart);
            this._rightPart.x = 504;
            this._rightPart.y = 37;
            this._window.contentTopOf3DSprite.addChild(this._rightPart);
            this._equipMentPart = UICompomentPool.getUICompoment(MountEquipPart);
            this._equipMentPart.x = 20;
            this._equipMentPart.y = 195;
            this._equipMentPart.alpha = 1;
            this._window.contentTopOf3DSprite.addChild(this._equipMentPart);
            this._leftBtn = UIFactory.gLoadedButton(ImagesConst.TurnLeft2_upSkin, 332, 220, 40, 36, this._equipMentPart);
            this._leftBtn.configEventListener(MouseEvent.MOUSE_DOWN, this.onClickTurnBtn);
            this._rightBtn = UIFactory.gLoadedButton(ImagesConst.TurnRight2_upSkin, 91, 220, 40, 36, this._equipMentPart);
            this._rightBtn.configEventListener(MouseEvent.MOUSE_DOWN, this.onClickTurnBtn);
            Global.stage.addEventListener(MouseEvent.MOUSE_UP, this.stopTurning);
            this._mountAdvancePanel = UICompomentPool.getUICompoment(MountAdvancePanel);
            this._mountAdvancePanel.x = 15;
            this._mountAdvancePanel.y = 170;
            this._mountAdvancePanel.visible = false;
            this._window.contentTopOf3DSprite.addChild(this._mountAdvancePanel);
            this._skillPart = UICompomentPool.getUICompoment(MountSkillPart);
            this._skillPart.x = 20;
            this._skillPart.y = 493;
            this._window.contentTopOf3DSprite.addChild(this._skillPart);
            this._advanceLevelSprite = UICompomentPool.getUICompoment(GSprite);
            this._advanceLevelSprite.x = 35;
            this._advanceLevelSprite.y = 473;
            this._rightPart.addChild(this._advanceLevelSprite);
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.SystemAdvanceBg, 20, -123, this._advanceLevelSprite));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.SystemAdvanceBg, 115, -123, this._advanceLevelSprite));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.SystemAdvanceArrow, 68, -116, this._advanceLevelSprite));
            this._currLevel = UIFactory.bitmapNumberText(41, -116, "GuildNewBuildingNum2.png", 21, 24, -10, this._advanceLevelSprite, 13, 1);
            this._nextLevel = UIFactory.bitmapNumberText(136, -116, "GuildNewBuildingNum2.png", 21, 24, -10, this._advanceLevelSprite, 13, 1);
            this._adVanceBtnSprite = UICompomentPool.getUICompoment(GSprite);
            this._adVanceBtnSprite.x = 35;
            this._adVanceBtnSprite.y = 473;
            this._rightPart.addChild(this._adVanceBtnSprite);
            this._nolmalLevelUpBtn = UIFactory.gLoadingButton(ResFileConst.SystemAdvanceBtn, -17, 1, 114, 33, this._adVanceBtnSprite);
            this._nolmalLevelUpBtn.name = "mount_normalLevelUpBtn";
            this._nolmalLevelUpBtn.drawNow();
            this._autoLevelUpBtn = UIFactory.gLoadingButton(ResFileConst.SystemAutoAdvanceBtn, 94, 1, 114, 33, this._adVanceBtnSprite);
            this._autoLevelUpBtn.drawNow();
            this._autoLevelUpBtn.visible = true;
            this._cancelBtn = UIFactory.gLoadingButton(ResFileConst.CancelAdvanceBtn, 94, 1, 114, 33, this._adVanceBtnSprite);
            this._cancelBtn.drawNow();
            this._cancelBtn.visible = false;
            this._autoBuy = UIFactory.checkBox(Language.getString(35424), 24, 43, 210, 28, this._adVanceBtnSprite);
            this._autoBuy.selected = this._isAutoBuy;
            this._autoBuy.configEventListener(Event.CHANGE, this.selectedChangeHandler);
            this._levelUpIcon = UIFactory.gImageBitmap(ImagesConst.MountLevelUpIcon, 195, 277, this._window.contentTopOf3DSprite);
            this._levelUpIcon.visible = false;
            this._sharpBtn = UIFactory.gLoadingButton(ResFileConst.TurnedBtn, 425, 80, 49, 52, this._window.contentTopOf3DSprite);
            this._sharpBtn.configEventListener(MouseEvent.CLICK, this.sharpMount);
            this._sharpBtn.drawNow();
            LoaderHelp.setBitmapdata("mountInfoRightBg.swf", this._mountBg, 0, 0, -1, -1, this.add2d);
            this.updateMountInfo();
            this.updateMountItem();
            this.updateEquip();
            this.updateMountSharpItem();
            this.updateVip();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._nolmalLevelUpBtn.name = "";
            SevenDayLoginUtil.removeArrow(this._nolmalLevelUpBtn);
            this._skillPart.dispose(param1);
            this._skillPart = null;
            this._mountBg.dispose(param1);
            this._mountBg = null;
            this._name.dispose(param1);
            this._name = null;
            this._vipIcon.dispose(param1);
            this._vipIcon = null;
            this.vipSp.dispose(param1);
            this.vipSp = null;
            this._turnLeftBtn.dispose(param1);
            this._turnLeftBtn = null;
            this._turnRightBtn.dispose(param1);
            this._turnRightBtn = null;
            this._3dRotationBm.dispose(param1);
            this._3dRotationBm = null;
            this._3dRotationSp.dispose(param1);
            this._3dRotationSp = null;
            this._equipMentPart.dispose(param1);
            this._equipMentPart = null;
            this._sharpBtn.dispose(param1);
            this._sharpBtn = null;
            this._rightPart.dispose(param1);
            this._rightPart = null;
            this._nolmalLevelUpBtn.dispose(param1);
            this._nolmalLevelUpBtn = null;
            this._cancelBtn.dispose(param1);
            this._cancelBtn = null;
            this._autoLevelUpBtn.dispose(param1);
            this._autoLevelUpBtn = null;
            this._autoBuy.dispose(param1);
            this._autoBuy = null;
            this._levelUpIcon.dispose(param1);
            this._levelUpIcon = null;
            this._advanceLevelSprite.dispose(param1);
            this._advanceLevelSprite = null;
            this._currLevel.dispose();
            this._currLevel = null;
            this._nextLevel.dispose();
            this._nextLevel = null;
            this._leftBtn.dispose(param1);
            this._leftBtn = null;
            this._rightBtn.dispose(param1);
            this._rightBtn = null;
            this._mountAdvancePanel.dispose(param1);
            this._mountAdvancePanel = null;
            this._adVanceBtnSprite.dispose(param1);
            this._adVanceBtnSprite = null;
            if (this._mountHangEffect)
            {
                this._mountHangEffect.dispose(param1);
                this._mountHangEffect = null;
            }
            if (this._nextMountHangEffect)
            {
                this._nextMountHangEffect.dispose(param1);
                this._nextMountHangEffect = null;
            }
            if (this._rect3d)
            {
                Rect3DManager.instance.disposeRect3d(this._rect3d);
                this._rect3d.disposeObj3d(this._bodyPlayer);
                this._rect3d.disposeObj3d(this._nextBodyPlayer);
                this._nextBodyPlayer = null;
                this._bodyPlayer = null;
                this._rect3d = null;
                this._img2d = null;
            }
            if (BuyGiftItemWin.isViewShow)
            {
                BuyGiftItemWin.instance.hide();
            }
            this.stopTurning();
            Global.stage.removeEventListener(MouseEvent.MOUSE_UP, this.stopTurn);
            Global.stage.removeEventListener(MouseEvent.MOUSE_DOWN, this.startTurn);
            Global.stage.removeEventListener(MouseEvent.MOUSE_UP, this.stopTurning);
            Dispatcher.removeEventListener(EventName.ShopBuyItemFail, this.cancelAutoLevelUp);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
            if (this._delayTimer)
            {
                this._delayTimer.stop();
                this._delayTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, this.delayTimerHandler);
                this._delayTimer = null;
            }
            this._isOverBtn = false;
            this._isUseUnBinGold = false;
            this._mountData = null;
            this._tmountInfo = null;
            this.killTween();
            GiftsUtil.clearNotToUseGiftDic();
            super.disposeImpl(param1);
            return;
        }// end function

        private function showEffect(event:MouseEvent) : void
        {
            if (!VipConfig.instance.isShowEffect(EVipRecordType._EVipRecordTypeMountEffect, Cache.instance.vip.level))
            {
                this.addMountEffect();
            }
            return;
        }// end function

        private function hideEffect(event:MouseEvent) : void
        {
            if (!VipConfig.instance.isShowEffect(EVipRecordType._EVipRecordTypeMountEffect, Cache.instance.vip.level))
            {
                if (this._mountHangEffect)
                {
                    this._rect3d.disposeObj3d(this._mountHangEffect);
                    this._mountHangEffect = null;
                }
            }
            return;
        }// end function

        protected function onClickTurnBtn(event:MouseEvent) : void
        {
            if (this._bodyPlayer)
            {
                if (event.currentTarget == this._leftBtn)
                {
                    this.turnValue = 2;
                }
                if (event.currentTarget == this._rightBtn)
                {
                    this.turnValue = -2;
                }
                this.start();
            }
            return;
        }// end function

        protected function stopTurning(event:MouseEvent = null) : void
        {
            if (this._frameTimer)
            {
                this._frameTimer.stop();
            }
            return;
        }// end function

        protected function onTurning(param1:FrameTimer) : void
        {
            if (this._bodyPlayer)
            {
                this._bodyPlayer.rotationY = this._bodyPlayer.rotationY + this.turnValue;
            }
            return;
        }// end function

        private function start() : void
        {
            if (!this._frameTimer)
            {
                this._frameTimer = new FrameTimer(1, int.MAX_VALUE, true);
                this._frameTimer.addListener(TimerType.ENTERFRAME, this.onTurning);
            }
            this._frameTimer.start();
            return;
        }// end function

        private function startTurn(event:MouseEvent) : void
        {
            this._startX = this.mouseX;
            this._3dRotationSp.configEventListener(MouseEvent.MOUSE_MOVE, this.turning);
            return;
        }// end function

        private function stopTurn(event:MouseEvent) : void
        {
            this._3dRotationSp.removeEventListener(MouseEvent.MOUSE_MOVE, this.turning);
            return;
        }// end function

        private function turning(event:MouseEvent) : void
        {
            this._endX = this.mouseX;
            this._bodyPlayer.rotationY = this._bodyPlayer.rotationY - (this._endX - this._startX) / 3;
            this._startX = this._endX;
            if (this._tween3)
            {
                this._tween3.kill();
            }
            return;
        }// end function

        private function upgradeHandler(event:MouseEvent) : void
        {
            if (this._mountData.sPublicMount.code == MountUtil.maxMountLevel)
            {
                return MsgManager.showRollTipsMsg(Language.getString(35425));
            }
            if (event.target == this._nolmalLevelUpBtn)
            {
                this.cancelAutoLevelUp();
                this.levelUpHandler();
            }
            else if (event.target == this._autoLevelUpBtn)
            {
                this._cancelBtn.visible = true;
                this._autoLevelUpBtn.visible = false;
                this._isAntoLeveling = true;
                this.levelUpHandler();
            }
            else if (event.target == this._cancelBtn)
            {
                this.cancelAutoLevelUp();
            }
            return;
        }// end function

        private function getAdvanceItem(param1:int, param2:int, param3:Dictionary) : int
        {
            var _loc_4:int = 0;
            var _loc_7:ItemData = null;
            var _loc_8:int = 0;
            var _loc_5:* = Cache.instance.pack.backPackCache.getItemsByGroupCategoryAndType(EGroup._EGroupStuff, EStuff._EStuffAdvance, param1);
            _loc_5.sort(this.sortItem);
            var _loc_6:* = _loc_5.length;
            while (_loc_8 < _loc_6)
            {
                
                _loc_7 = _loc_5[_loc_8] as ItemData;
                if (ItemsUtil.isPrescriOutTime(_loc_7))
                {
                }
                else if (_loc_7.itemInfo.effectEx == 1)
                {
                }
                else if (this._mountData.mountLevel >= _loc_7.itemInfo.effect)
                {
                    _loc_4 = _loc_4 + (_loc_5[_loc_8] as ItemData).itemAmount;
                    param3[_loc_7.uid] = _loc_7.itemAmount;
                    if (_loc_4 >= param2)
                    {
                        param3[_loc_7.uid] = _loc_7.itemAmount - _loc_4 + param2;
                        break;
                    }
                }
                _loc_8++;
            }
            return _loc_4;
        }// end function

        public function levelUpHandler(param1:Object = null) : void
        {
            var _loc_4:int = 0;
            var _loc_7:int = 0;
            var _loc_8:ItemInfo = null;
            var _loc_9:ShopItemData = null;
            var _loc_10:int = 0;
            var _loc_11:Boolean = false;
            SevenDayLoginUtil.removeArrow(this._nolmalLevelUpBtn);
            var _loc_2:* = new Dictionary();
            var _loc_3:* = this._mountData.tMountConfig.propNum;
            var _loc_5:* = MountUtil.isHasBlessItem(EAdvanceType._EAdvanceMountAdvanced);
            if (_loc_5)
            {
                _loc_2[_loc_5.uid] = 1;
            }
            else
            {
                _loc_4 = this.getAdvanceItem(EAdvanceType._EAdvanceMountAdvanced, _loc_3, _loc_2);
                if (_loc_4 < _loc_3)
                {
                    _loc_7 = this.getAdvanceItem(EAdvanceType._EAdvanceTypeAllRoundUp, _loc_3 - _loc_4, _loc_2);
                    _loc_4 = _loc_4 + _loc_7;
                }
            }
            var _loc_6:* = new Object();
            _loc_6.autoBuy = this._autoBuy.selected;
            _loc_6.dic = _loc_2;
            _loc_6.isAutoLevelUp = this._isAntoLeveling;
            if (_loc_5 || _loc_4 >= _loc_3)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MountLevelUp, _loc_6));
            }
            else
            {
                _loc_8 = ItemConfig.instance.getConfig(int(this._mountData.tMountConfig.propConsume));
                if (this._isAutoBuy)
                {
                    _loc_9 = ShopConfig.instance.getFastBuyItemByCode(_loc_8.bind ? (_loc_8.codeUnbind) : (_loc_8.code));
                    _loc_10 = _loc_9.prize * (_loc_3 - _loc_4);
                    _loc_11 = Cache.instance.role.enoughMoney(EPriceUnit._EPriceUnitGoldBind, _loc_10, null, false);
                    if (_loc_11)
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.MountLevelUp, _loc_6));
                    }
                    else
                    {
                        this.showGiftToUse(_loc_8, _loc_3 - _loc_4);
                    }
                }
                else if (GuideController.currentGuideItemWin == ModuleType.Mounts)
                {
                    MsgManager.showMouseMsg(Language.getString(35426), MsgRollTipsType.msgRollTips3);
                    GameController.playerSystem.view.hide();
                    GuideController.currentGuideItemWin = null;
                    this.cancelAutoLevelUp();
                }
                else
                {
                    this.showGiftToUse(_loc_8, _loc_3 - _loc_4);
                }
            }
            return;
        }// end function

        private function showGiftToUse(param1:ItemInfo, param2:int) : void
        {
            if (GiftsUtil.isCanUseFreeGift(param1.group, param1.category, param1.type, int.MAX_VALUE, EGiftBag._EGiftBagFix))
            {
                MsgManager.showRollTipsMsg(Language.getString(35427));
                this.cancelAutoLevelUp();
                return;
            }
            if (BuyGiftItemWin.isViewShow && BuyGiftItemWin.isAutoBuy)
            {
                BuyGiftItemWin.isNeedTobuyCurTime = true;
                Dispatcher.addEventListener(EventName.ShopBuyItemFail, this.shopBuyItemFail);
                NetDispatcher.addCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
            }
            else
            {
                MsgManager.showMouseMsg(Language.getString(35426), MsgRollTipsType.msgRollTips3);
                this.cancelAutoLevelUp();
            }
            BuyGiftItemWin.instance.setBuyData(param1.code, 2, param2, this._window.x + this._window.width + 5, this._window.y - 3);
            return;
        }// end function

        private function keepLevelUp(param1:Array) : void
        {
            var _loc_2:* = param1[0] as ItemData;
            if (ItemsUtil.isMountAdvanced(_loc_2))
            {
                Dispatcher.removeEventListener(EventName.ShopBuyItemFail, this.shopBuyItemFail);
                NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
                this.levelUpHandler();
            }
            return;
        }// end function

        private function shopBuyItemFail(event:DataEvent) : void
        {
            this.cancelAutoLevelUp();
            return;
        }// end function

        private function sortItem(param1:ItemData, param2:ItemData) : int
        {
            if (!ItemsUtil.isPrescriptionItem(param1) && ItemsUtil.isPrescriptionItem(param2))
            {
                return 1;
            }
            if (ItemsUtil.isPrescriptionItem(param1) && !ItemsUtil.isPrescriptionItem(param2))
            {
                return -1;
            }
            if (param1.itemInfo.effect > param2.itemInfo.effect)
            {
                return -1;
            }
            if (param1.itemInfo.effect < param2.itemInfo.effect)
            {
                return 1;
            }
            if (param1.bind == EBind._EBindYes && param2.bind == EBind._EBindNo)
            {
                return -1;
            }
            return 1;
        }// end function

        private function getVipToolTip() : String
        {
            var _loc_3:String = null;
            var _loc_1:* = VipConfig.instance.getVipConfigByType(EVipRecordType._EVipRecordTypeMountEffect);
            var _loc_2:* = VipUtil.getVipMinLevelByType(EVipRecordType._EVipRecordTypeMountEffect);
            _loc_3 = Language.getStringByParam(35428, _loc_2, _loc_1.desc);
            return _loc_3;
        }// end function

        private function selectedChangeHandler(event:Event) : void
        {
            this._isAutoBuy = this._autoBuy.selected;
            return;
        }// end function

        private function add2d() : void
        {
            if (this.isDisposed)
            {
                return;
            }
            this.add3d();
            this.update3Dmount();
            this._img2d = new Img2D(null, this._mountBg.bitmapData, new Rectangle(0, 0, 490, 546), false);
            this._rect3d.addImg(this._img2d);
            Global.stage.addEventListener(MouseEvent.MOUSE_DOWN, this.startTurn);
            Global.stage.addEventListener(MouseEvent.MOUSE_UP, this.stopTurn);
            this._adVanceBtnSprite.configEventListener(MouseEvent.CLICK, this.upgradeHandler);
            this._adVanceBtnSprite.configEventListener(MouseEvent.ROLL_OVER, this.showAttrUp);
            this._adVanceBtnSprite.configEventListener(MouseEvent.ROLL_OUT, this.hideAttrUp);
            this._turnRightBtn.configEventListener(MouseEvent.CLICK, this.updatePage);
            this._turnLeftBtn.configEventListener(MouseEvent.CLICK, this.updatePage);
            return;
        }// end function

        private function add3d() : void
        {
            if (!this._rect3d)
            {
                this._rect3d = Rect3DManager.instance.registerWindow(true, new Rectangle(11, 38, 490, 546), this._window);
            }
            Rect3DManager.instance.windowShowHander(null, this._window);
            return;
        }// end function

        public function onWindowDragEnd() : void
        {
            this.killTween();
            if (this._rect3d)
            {
                this._rect3d.addObject3d(this._bodyPlayer, 245, 375);
                this.modelX = this._bodyPlayer.x;
            }
            return;
        }// end function

        protected function update3Dmount() : void
        {
            var _loc_1:TModel = null;
            var _loc_2:String = null;
            var _loc_3:String = null;
            var _loc_4:MountData = null;
            if (this._rect3d && this._mountData)
            {
                _loc_1 = ModelConfig.instance.getInfoByCode(this._tmountInfo.modelId);
                _loc_2 = _loc_1.mesh1 + ".md5mesh";
                _loc_3 = _loc_1.bone1 + ".skeleton";
                if (this._bodyPlayer == null)
                {
                    this._bodyPlayer = FrObjectPool.getObject(ActionPlayer, this);
                }
                if (this._bodyPlayer.meshUrl != _loc_2 && this._bodyPlayer.animUrl != _loc_3)
                {
                    this._bodyPlayer.load(_loc_2, _loc_3, _loc_1.texture1, this._rect3d.renderList);
                }
                this._bodyPlayer.changeAction(ActionName.MountStand);
                this._bodyPlayer.scaleValue = 1.3;
                this._bodyPlayer.alpha = 1;
                if (this._currentIndex == 10)
                {
                    this._bodyPlayer.rotationY = 0;
                }
                else
                {
                    this._bodyPlayer.rotationY = 50;
                }
                this._bodyPlayer.play();
                this._rect3d.addObject3d(this._bodyPlayer, 245, 375);
                this.modelX = this._bodyPlayer.x;
                if (VipConfig.instance.isShowEffect(EVipRecordType._EVipRecordTypeMountEffect, Cache.instance.vip.level))
                {
                    this.addMountEffect();
                }
                if (this._isOverBtn)
                {
                    _loc_4 = new MountData((this._mountData.sPublicMount.code + 1));
                    if (_loc_4.tMountConfig)
                    {
                        this.updateNext3Dmount(_loc_4, true);
                    }
                }
            }
            return;
        }// end function

        private function addMountEffect() : void
        {
            var _loc_1:TModel = null;
            if (this._rect3d && this._mountData)
            {
                _loc_1 = ModelConfig.instance.getInfoByCode(this._tmountInfo.modelId);
                if (this._mountHangEffect)
                {
                    this._rect3d.disposeObj3d(this._mountHangEffect);
                    this._mountHangEffect = null;
                }
                if (_loc_1.effect1)
                {
                    this._mountHangEffect = EffectPlayerPool.instance.getEffectPlayer(_loc_1.effect1, this._bodyPlayer, this._rect3d.renderList, false);
                    if (this._mountHangEffect.temple is TempleRole)
                    {
                        (this._mountHangEffect.temple as TempleRole).setRoleParams(this._bodyPlayer, null, null);
                    }
                    this._mountHangEffect.play(PlayMode.ANIMATION_LOOP_MODE);
                }
            }
            return;
        }// end function

        private function updateNext3Dmount(param1:MountData, param2:Boolean = false) : void
        {
            var _loc_3:TModel = null;
            var _loc_4:String = null;
            var _loc_5:String = null;
            if (this._rect3d)
            {
                _loc_3 = ModelConfig.instance.getInfoByCode(param1.tMountConfig.modelId);
                _loc_4 = _loc_3.mesh1 + ".md5mesh";
                _loc_5 = _loc_3.bone1 + ".skeleton";
                if (this._nextBodyPlayer == null)
                {
                    this._nextBodyPlayer = FrObjectPool.getObject(ActionPlayer, this);
                }
                if (this._nextBodyPlayer.meshUrl != _loc_4 && this._nextBodyPlayer.animUrl != _loc_5)
                {
                    this._nextBodyPlayer.load(_loc_4, _loc_5, _loc_3.texture1, this._rect3d.renderList);
                }
                this._nextBodyPlayer.changeAction(ActionName.MountStand);
                this._nextBodyPlayer.play();
                this._nextBodyPlayer.scaleValue = 1.3;
                this._nextBodyPlayer.rotationY = 50;
                if (VipConfig.instance.isShowEffect(EVipRecordType._EVipRecordTypeMountEffect, Cache.instance.vip.level))
                {
                    if (this._nextMountHangEffect)
                    {
                        this._nextMountHangEffect.dispose(true);
                        this._nextMountHangEffect = null;
                    }
                    if (_loc_3.effect1)
                    {
                        this._nextMountHangEffect = EffectPlayerPool.instance.getEffectPlayer(_loc_3.effect1, this._nextBodyPlayer, this._rect3d.renderList, false);
                        if (this._nextMountHangEffect.temple is TempleRole)
                        {
                            (this._nextMountHangEffect.temple as TempleRole).setRoleParams(this._nextBodyPlayer, null, null);
                        }
                        this._nextMountHangEffect.play(PlayMode.ANIMATION_LOOP_MODE);
                    }
                }
                if (!param2)
                {
                    this._rect3d.addObject3d(this._nextBodyPlayer, 245, 375);
                    this._nextBodyPlayer.alpha = 0.1;
                }
            }
            return;
        }// end function

        private function playEndHander(event:Event) : void
        {
            return;
        }// end function

        private function delayTimerHandler(event:TimerEvent) : void
        {
            this.showAttrUp();
            this._delayTimer.stop();
            this._delayTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, this.delayTimerHandler);
            return;
        }// end function

        private function showAttrUp(event:MouseEvent = null) : void
        {
            if (event)
            {
                if (this._delayTimer == null)
                {
                    this._delayTimer = new Timer(200, 1);
                }
                this._delayTimer.addEventListener(TimerEvent.TIMER_COMPLETE, this.delayTimerHandler);
                this._delayTimer.start();
                return;
            }
            if (this._mountData && this._mountData.sPublicMount.code == MountUtil.maxMountLevel)
            {
                return;
            }
            this._isOverBtn = true;
            if (this._tween2 && this._tween2.active)
            {
            }
            else
            {
                this.modelX = this._bodyPlayer.x;
            }
            this.killTween();
            var _loc_2:* = new MountData((this._mountData.sPublicMount.code + 1));
            this.updateNext3Dmount(_loc_2);
            this._bodyPlayer.rotationY = this._bodyPlayer.rotationY % 360;
            this._tween1 = TweenMax.to(this._bodyPlayer, 0.7, {x:this.modelX - 150, rotationY:-50, ease:Quint.easeOut});
            if (this._nextBodyPlayer && this._nextBodyPlayer.x != this.modelX + 150)
            {
                this._tween2 = TweenMax.to(this._nextBodyPlayer, 0.7, {x:this.modelX + 150, alpha:0.6, ease:Quint.easeOut});
            }
            this._tween3 = TweenMax.to(this._equipMentPart, 0.7, {alpha:0, ease:Quint.easeOut});
            this._mountAdvancePanel.visible = true;
            this._mountAdvancePanel.setName(this._mountData.tMountConfig, _loc_2.tMountConfig);
            this._levelUpIcon.visible = true;
            this._rightPart.showAttrUp();
            return;
        }// end function

        private function hideAttrUp(event:MouseEvent = null) : void
        {
            if (this.isDisposed)
            {
                return;
            }
            if (this._delayTimer && this._delayTimer.running)
            {
                this._delayTimer.stop();
                this._delayTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, this.delayTimerHandler);
                return;
            }
            this.killTween();
            if (this._nextMountHangEffect)
            {
                this._nextMountHangEffect.dispose(true);
                this._nextMountHangEffect = null;
            }
            this._isOverBtn = false;
            if (event && event.currentTarget.visible == false && this._mountData.sPublicMount.code < 10)
            {
                return;
            }
            this._rightPart.hideAttrUp();
            this._tween1 = TweenMax.to(this._bodyPlayer, 0.5, {x:this.modelX, rotationY:50, ease:Quint.easeOut});
            if (this._nextBodyPlayer && this._nextBodyPlayer.x != this.modelX)
            {
                this._tween2 = TweenMax.to(this._nextBodyPlayer, 1, {x:this.modelX, alpha:0.02, ease:Quint.easeOut, onComplete:this.onShowEnd});
            }
            this._tween3 = TweenMax.to(this._equipMentPart, 0.5, {alpha:1, ease:Quint.easeOut});
            this._mountAdvancePanel.visible = false;
            this._levelUpIcon.visible = false;
            return;
        }// end function

        private function killTween() : void
        {
            if (this._tween1)
            {
                this._tween1.kill();
            }
            if (this._tween2)
            {
                this._tween2.kill();
            }
            if (this._tween3)
            {
                this._tween3.kill();
            }
            return;
        }// end function

        private function onShowEnd() : void
        {
            if (this._rect3d)
            {
                this._rect3d.disposeObj3d(this._nextBodyPlayer);
                this._nextBodyPlayer = null;
            }
            return;
        }// end function

        private function updatePage(event:MouseEvent = null) : void
        {
            var _loc_2:int = 0;
            if (event.currentTarget == this._turnLeftBtn)
            {
                this._currentIndex = this._currentIndex == 1 ? (1) : ((this._currentIndex - 1));
            }
            else if (event.currentTarget == this._turnRightBtn)
            {
                _loc_2 = this._mountData.mountLevel;
                this._currentIndex = this._currentIndex == _loc_2 ? (_loc_2) : ((this._currentIndex + 1));
            }
            this._tmountInfo = MountConfig.instance.getMountInfoByCode(this._currentIndex);
            this._name.imgUrl = "MountName_" + this._currentIndex;
            this._rightPart.updateName(this._currentIndex);
            this.update3Dmount();
            this.updatePageBtn();
            this.updateMountSelect();
            return;
        }// end function

        private function updatePageBtn() : void
        {
            this._turnLeftBtn.filterEnabled = this._currentIndex != 1;
            this._turnRightBtn.filterEnabled = this._currentIndex < this._mountData.mountLevel;
            return;
        }// end function

        public function updateMountInfo() : void
        {
            var _loc_1:MountData = null;
            this._mountData = Cache.instance.mount.mountData;
            if (this._mountData.sPublicMount.sharpId > 10000)
            {
                this._currentIndex = this._mountData.mountLevel;
            }
            else
            {
                this._currentIndex = this._mountData.sPublicMount.sharpId;
            }
            this._tmountInfo = MountConfig.instance.getMountInfoByCode(this._currentIndex);
            this._name.imgUrl = "MountName_" + this._tmountInfo.code;
            this._rightPart.updateMountInfo(this._mountData, this._tmountInfo);
            this._equipMentPart.updateMountInfo(this._mountData);
            this._skillPart.updateSkillGrid(this._mountData);
            if (this._mountData.mountLevel < MountUtil.maxMountLevel)
            {
                _loc_1 = new MountData((this._mountData.sPublicMount.code + 1));
                this._currLevel.text = "" + this._mountData.mountLevel;
                this._nextLevel.text = "" + _loc_1.mountLevel;
                var _loc_2:Boolean = true;
                this._adVanceBtnSprite.mouseEnabled = true;
                this._adVanceBtnSprite.mouseChildren = _loc_2;
                this._advanceLevelSprite.visible = true;
                var _loc_2:Boolean = true;
                this._autoLevelUpBtn.filterEnabled = true;
                this._nolmalLevelUpBtn.filterEnabled = _loc_2;
            }
            else
            {
                var _loc_2:Boolean = false;
                this._adVanceBtnSprite.mouseEnabled = false;
                this._adVanceBtnSprite.mouseChildren = _loc_2;
                var _loc_2:Boolean = false;
                this._autoLevelUpBtn.filterEnabled = false;
                this._nolmalLevelUpBtn.filterEnabled = _loc_2;
                this._advanceLevelSprite.visible = false;
            }
            this._sharpBtn.visible = this._mountData.mountLevel >= 4;
            if (this._rect3d)
            {
                this.update3Dmount();
            }
            this.updatePageBtn();
            this.updateMountSelect();
            if (this._isOverBtn)
            {
                if (this._mountData.sPublicMount.code < 10)
                {
                    this.showAttrUp();
                }
                else
                {
                    this.hideAttrUp();
                }
            }
            return;
        }// end function

        public function cancelAutoLevelUp(param1:Object = null) : void
        {
            if (this._cancelBtn)
            {
                this._cancelBtn.visible = false;
            }
            if (this._autoLevelUpBtn)
            {
                this._autoLevelUpBtn.visible = true;
            }
            Dispatcher.removeEventListener(EventName.ShopBuyItemFail, this.shopBuyItemFail);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
            this._isAntoLeveling = false;
            return;
        }// end function

        private function sharpMount(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MountSharp, this._currentIndex));
            return;
        }// end function

        public function updateAttrData() : void
        {
            this._rightPart.updateAttrData();
            return;
        }// end function

        public function blessUpdate() : void
        {
            this._rightPart.blessUpdate();
            return;
        }// end function

        public function showBtnFilter() : void
        {
            var _loc_2:Boolean = false;
            var _loc_3:int = 0;
            var _loc_6:int = 0;
            var _loc_1:* = Cache.instance.pack.backPackCache.getItemsByGroupCategoryAndType(EGroup._EGroupStuff, EStuff._EStuffAdvance, EAdvanceType._EAdvanceMountAdvanced);
            var _loc_4:* = this._mountData.tMountConfig.propNum;
            var _loc_5:* = _loc_1.length;
            while (_loc_6 < _loc_5)
            {
                
                if (ItemsUtil.isPrescriOutTime(_loc_1[_loc_6] as ItemData))
                {
                }
                else if (this._mountData.mountLevel >= (_loc_1[_loc_6] as ItemData).itemInfo.effect)
                {
                    _loc_3 = _loc_3 + (_loc_1[_loc_6] as ItemData).itemAmount;
                }
                _loc_6++;
            }
            if (_loc_3 >= _loc_4)
            {
                SevenDayLoginUtil.genGiftArrow(this._nolmalLevelUpBtn, -10, 12, 2, this._nolmalLevelUpBtn.parent);
            }
            return;
        }// end function

        public function updateEquip() : void
        {
            this._equipMentPart.updateEquip();
            this._rightPart.updateAttrData();
            return;
        }// end function

        public function updateMountSharpItem() : void
        {
            this._equipMentPart.updateMountSharpItem();
            return;
        }// end function

        public function updateMountItem() : void
        {
            this._equipMentPart.updateMountItem();
            this._rightPart.updateLevelUpItem();
            this._skillPart.updateSkillbook();
            return;
        }// end function

        public function updateMountSelect() : void
        {
            if (this._currentIndex == this._mountData.sPublicMount.sharpId)
            {
                this._sharpBtn.enabled = false;
            }
            else
            {
                this._sharpBtn.enabled = true;
            }
            return;
        }// end function

        public function updateVip() : void
        {
            var _loc_1:* = VipConfig.instance.getValueByTypeAndLv(EVipRecordType._EVipRecordTypeMountEffect, Cache.instance.vip.level);
            var _loc_2:* = VipUtil.getVipMinLevelByType(EVipRecordType._EVipRecordTypeMountEffect);
            if (Cache.instance.vip.level >= _loc_2)
            {
                this._vipIcon.filters = [];
                this._vipIcon.imgUrl = GameDefConfig.instance.getVipLevelIconUrl(Cache.instance.vip.level, 2);
                this.updateMountInfo();
            }
            else
            {
                this._vipIcon.filters = [FilterConst.colorFilter2];
                this._vipIcon.imgUrl = GameDefConfig.instance.getVipLevelIconUrl(_loc_2, 2);
            }
            return;
        }// end function

        public function updateSkill(param1:SSkill) : void
        {
            var _loc_4:int = 0;
            var _loc_2:* = param1;
            var _loc_3:* = SkillConfig.instance.getInfoById(_loc_2.skillId);
            if (_loc_3)
            {
                _loc_4 = GameDefConfig.instance.getOtherSkillTypeByPosType(_loc_3.posType);
                if (_loc_4 == ESkillCategory._EMountSkill)
                {
                    this._skillPart.updateSkill();
                    this._rightPart.updateCombat();
                }
            }
            return;
        }// end function

        public function shapeCardStatUpdate(param1:Boolean) : void
        {
            this._equipMentPart.shapeCardStatUpdate();
            return;
        }// end function

    }
}
